/**
 * 
 */
package com.dsteiner.gwt.cafeteriasophia.client;

import com.dsteiner.gwt.cafeteriasophia.client.controller.ShiftChangeInfoController;
import com.dsteiner.gwt.cafeteriasophia.client.model.HistoryModel;
import com.dsteiner.gwt.cafeteriasophia.client.model.ShiftChangeInfoModel;
import com.dsteiner.gwt.cafeteriasophia.client.model.ShiftChangeModel;
import com.dsteiner.widgets.client.PopupOverlayWidget;
import com.dsteiner.widgets.client.Widgets.ButtonExt;
import com.dsteiner.widgets.client.Widgets.FlowPanelExt;
import com.dsteiner.widgets.client.Widgets.HTMLExt;
import com.dsteiner.widgets.client.Widgets.IWidget;
import com.dsteiner.widgets.client.Widgets.LazyWidget;
import com.dsteiner.widgets.client.model.PopupOverlayModel;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Widget;

public class ShiftChangeInfoWidget extends LazyWidget {


	private ShiftChangeInfoController shiftChangeInfoController = new ShiftChangeInfoController();
	private final ShiftChangeInfoModel shiftChangeInfoModel;
	private final HistoryModel historyModel;

	public ShiftChangeInfoWidget(ShiftChangeInfoModel shiftChangeInfoModel, HistoryModel historyModel) {
		this.shiftChangeInfoModel = shiftChangeInfoModel;
		this.historyModel = historyModel;
		setStyleName("shiftChangeInfo-widget");
	}

	@Override
	public Widget createContentWidget() {
		FlowPanel mainPanel = new FlowPanel();
		HTMLExt infoHtml = new HTMLExt();
		HTMLExt editLink = new HTMLExt("<a href=\"javascript:void(0);\">editar</a>");
		ShiftChangeModel shiftChangeModel = new ShiftChangeModel();
		ShiftChangeEditWidget shiftChangeInfoWidget = new ShiftChangeEditWidget(shiftChangeModel);
		PopupOverlayModel shiftChangeEditPopupOverlayModel = new PopupOverlayModel();
		PopupOverlayWidget popupOverlayWidget = new PopupOverlayWidget(shiftChangeEditPopupOverlayModel);
		FlowPanelExt updateShiftChangePanel = new FlowPanelExt();
		ButtonExt updateShiftChangeButton = new ButtonExt("actualizar cambio de turno");
		updateShiftChangePanel.add((Widget)shiftChangeInfoWidget);
		updateShiftChangePanel.add((Widget)updateShiftChangeButton);
		shiftChangeEditPopupOverlayModel.setContentWidget(updateShiftChangePanel);
		
		mainPanel.add(infoHtml);
		mainPanel.add(editLink);
		
		shiftChangeInfoController.registerUpdateShiftChangeButton(updateShiftChangeButton);
		shiftChangeInfoController.registerShiftChangeEditPopupOverlayModel(shiftChangeEditPopupOverlayModel);
		shiftChangeInfoController.registerShiftChangeModel(shiftChangeModel);
		shiftChangeInfoController.registerEditLink(editLink);
		shiftChangeInfoController.registerHistoryModel(historyModel);
		shiftChangeInfoController.registerInfoHtml(infoHtml);
		shiftChangeInfoController.registerShiftChangeInfoWidget(this);
		shiftChangeInfoController.registerShiftChangeInfoModel(shiftChangeInfoModel);
		return mainPanel;
	}

}